<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>定时器</title>
	</head>
	<body>
		
		<script>
			var id1=setTimeout(fun,2000);
			function fun(){
				confirm();
				location.href="http://www.baidu.com";
			}
			//clearTimeout(id1);        关闭一次定时器
			var id2=setInterval(fun2,300);
			var i=0;
			function fun2(){
				i++;
				console.log("关不掉"+i);
			}
			//clearInterval(id2);         关闭循环定时器
			
		</script>
		
		
		
	</body>
</html>